|
adypoly
|
 |
« on: September 30, 2002, 04:56:43 PM » |
|
Respected sir,
My name is sooraj, i hereby send u my 1st exersice,plz grade it.
regards Sooraj
[i:1cr6dwhp]Exercise 1: What is the exact output result of this code.[/i:1cr6dwhp]
[code:1cr6dwhp] #include <stdio.h>
main()
{
printf("Hi\nthere\nWhat is the output\n?");
} [/code:1cr6dwhp] Ans: OUTPUT:
Hi there What is the output ? ----------------------------------------------------------------------------------------------
[i:1cr6dwhp]Exercise 2: Write a program that declares two floating numbers. Initialize them with float values. Then print their sum and multiplication in two separate lines.[/i:1cr6dwhp] [code:1cr6dwhp] #include<stdio.h> void main(){ /*Declaring two decimal variables (floats)*/ float x,y; /*Intialising the variables*/ x=233.55; y=566.22; /*Printing the sum of the variables*/ printf("The sum of %f and %f is %f\n",x,y,x+y); printf("The product of %f and %f is %f",x,y,x*y); } [/code:1cr6dwhp] ----------------------------------------------------------------------------------------------
[i:1cr6dwhp]Exersise 3 : Write the output result of multiple function example in this lesson.[/i:1cr6dwhp] [code:1cr6dwhp] #include<stdio.h>
main()
{
printf("I am going inside test function now\n");
test();
printf("\nNow I am back from test function\n");
}
test()
{
int a,b;
a=1;
b=a+100;
printf("a is %d and b is %d",a,b);
} [/code:1cr6dwhp] Ans: OUTPUT I am going inside test function now a is 1 and b is 101 Now I am back from test function ----------------------------------------------------------------------------------------------
[i:1cr6dwhp]Exercise 4: Why these variable names are not valid ? [/i:1cr6dwhp]
test$var - $ symbol is not allowed in variable declaration, You can use letters, digits and underscore (_) character to make your variable names.
my counter - " "(blank space) is also taken as a character which is also not allowed in variable declaration
9count - First character in a variable name must be a letter or an underscore (_) character.
float - A variable name cannot be a C programming language-reserved word (i.e. Commands and pre defined function names etc)
|