Friday, 12 February 2016
Saturday, 6 February 2016
What are the differences between %f, %e and %g format specifiers in C language? Explain with examples in which these format specifiers are emplyed.
- %f prints the corresponding number as a decimal floating point number (e.g. 321.65),
- %e prints the number in scientific notation (e.g. 3.2165e+2),
- %g prints the number in the shortest of these two representations (using the same number, the decimal floating point is shorter and hence 321.65 would be printed. An example where %g would print the scientific notation is when the number is 6000000000. In scientific notation, this would 6e+9 which is shorter and hence, 6e+9 would be printed.)
- The only difference between the lower case %e, %g and the upper case versions %E, %G is that printing scientific notation will use an upper case E instead of a lower case e to indicate the exponent. E.g. %E produces 3.2165E+2 when %e produces 3.2165e+2.
Friday, 5 February 2016
Right program of goto keyword
int main() { int age; printf("Enter you age:"); scanf("%d", &age); if(age>=18) goto Vote; else goto NoVote;Vote: printf("you are eligible for voting"); exit(); NoVote: printf("you are not eligible to vote");exit();return 0; }
Best example of goto keyword
Program to Print whether the number is even or odd
#include<stdio.h>
main(){
int n;
printf(''Enter the number :");
scanf("%d",&n);
if(n%2= = 0){
goto even;
}
else{
goto odd;
}
even :
printf("Number is even");
goto end;
odd :
printf("Number is odd ");
goto end;
end:
printf("\n");
getch();
return 0;
}
Subscribe to:
Posts
(
Atom
)