C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - General Questions (Q.No. 1)
1.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
Answer: Option
Explanation:
fmod(x,y) - Calculates x modulo y, the remainder of x/y.
This function is the same as the modulus operator. But fmod() performs floating point divisions.
Example:
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("fmod of 3.14/2.1 is %lf\n", fmod (3.14,2.1) );
return 0;
}
Output:
fmod of 3.14/2.1 is 1.040000
Discussion:
141 comments Page 2 of 15.
Shambhu kumar said:
1 decade ago
What is wrong in this code why it will give segmentation fault?
#include <stdio.h>
void main()
{
register int x = 0;
if (x < 2)
{
x++;
main();
}
}
#include <stdio.h>
void main()
{
register int x = 0;
if (x < 2)
{
x++;
main();
}
}
Manoj kumar said:
1 decade ago
External declaration means Declaring any variable before main() function or after main() function but not in main() function.
Example :
#include<stdio.h>
int S_no ;
main()
{
S_no=10;
printf ("%d\n",S_no);
}
Here I declared S_no Externally
Example :
#include<stdio.h>
int S_no ;
main()
{
S_no=10;
printf ("%d\n",S_no);
}
Here I declared S_no Externally
Pooja said:
1 decade ago
@Vani.
printf inside the printf....firstly there is a abc and also a slace is a character literal so there it work as a character...and 1 char is 1 byte so 4 character print 4...on place of printf("%d",4 );
Due to %d it'll print 4.
printf inside the printf....firstly there is a abc and also a slace is a character literal so there it work as a character...and 1 char is 1 byte so 4 character print 4...on place of printf("%d",4 );
Due to %d it'll print 4.
Subrat said:
8 years ago
#include <stdio.h>
#include <math.h>
int main ()
{
float 3.13.2.1;
float R;
R=fmod(3.14,2.1);
printf ("The remainder is:",R);
scanf("%f",R);
return 0;
}
It will show error, because you write
float 3.13.2.
#include <math.h>
int main ()
{
float 3.13.2.1;
float R;
R=fmod(3.14,2.1);
printf ("The remainder is:",R);
scanf("%f",R);
return 0;
}
It will show error, because you write
float 3.13.2.
Gayathridhiravidamani said:
1 decade ago
#include<stdio.h>
main()
{
float a=3.14,b=2.1,c;
c=a%b;
pf("%d",c);
output: invalid operand to binary%
BUT
int a;
a=3.14%2.1;
pf("%d",a);
Output 1:
I think so, comma act as a operator. Please clear explanation.
main()
{
float a=3.14,b=2.1,c;
c=a%b;
pf("%d",c);
output: invalid operand to binary%
BUT
int a;
a=3.14%2.1;
pf("%d",a);
Output 1:
I think so, comma act as a operator. Please clear explanation.
PRIYANKA said:
10 years ago
Modulus support only integers. For ex: If we take 16.25/2.5 then in modulus it take only 16 from 16.25 and from 2.5 it takes 2 and gives answer 4. It performs on integers only.
fmod gives reminder in float.
Hope it clear.
fmod gives reminder in float.
Hope it clear.
Gaurav said:
9 years ago
fmod() function is used to find out remainder of float numbers, not integer and normal operation like rem=12%7, it gives remainder only integer not float.
So option 1 is wrong and the correct is c.
I think you understand.
So option 1 is wrong and the correct is c.
I think you understand.
Sreedhar said:
1 decade ago
Hi friends, please help me how give below program output -80 ?
#include<stdio.h>
#define ABC 20
#define XYZ 10
#define XXX ABC - XYZ
void main()
{
int a;
a = XXX * 10;
printf("%d\n", a);
}
#include<stdio.h>
#define ABC 20
#define XYZ 10
#define XXX ABC - XYZ
void main()
{
int a;
a = XXX * 10;
printf("%d\n", a);
}
Prtk15 said:
1 decade ago
There is a new data-type which can take as values natural numbers between (and including) 0 and 25. How many minimum bits are required to store this data-type?
What will be its answer? Can anybody help me?
What will be its answer? Can anybody help me?
DINESH KUMAR I said:
1 decade ago
The output of following program is:
#include<stdio.h>
int main()
{
int a=1;
printf("%d %d %d",a,a++,++a);
return 0;
}
Output : 3 2 3.
But logically 3 2 2.
Can any explain how 3 2 3 comes?
#include<stdio.h>
int main()
{
int a=1;
printf("%d %d %d",a,a++,++a);
return 0;
}
Output : 3 2 3.
But logically 3 2 2.
Can any explain how 3 2 3 comes?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers