To generate the series 1+3+5+7+... using C program
Answers were Sorted based on User's Feedback
Answer / shiva
for(int a=0;a<10;a++){
(a&1)?printf("%d\n",a):printf("\n");
}
Is This Answer Correct ? | 8 Yes | 6 No |
Answer / nasif
#include<stdio.h>
int main()
{
int n,i,d=1,sum=0;
scanf("%d", &n);
for(i=1;i<=n;d=d+2){
sum=sum+d;
i++;
}
printf("summation is %d", sum);
return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / meheka
#inclined <stdio.h>
int main ()
{
int I=1,n,sum=0;
scanf("%d",&n);
while(i<=n)
sum=sum+I;
{
printf("%d",sum);
I=I+2;
}
return 0:
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / beetha poulose
#include<include>
int main ()
{
int j,i,n,sum=0;
Print("enter n");
scanf ("%d",&n);
For (i=1,j=1; j<=n; i=i+5,j++)
{
Sum=sum +i;
}
Prinrf ("sym=%d",sum);
Return 0;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / nishant
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=1,sum=0;
clrscr();
printf("enter the value for n:");
scanf("%d",&n);
while(i<=n)
{
sum=sum+i;
i=i+2;
}
printf("the series is =%d");
getch()
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / aditya parashar
#include<iostream.h>
void main ()
{int s,n;
cout <<"For finding sum of series
1+3+5.. till n terms enter value of n: ";
cin>>n;
s=n*n;
cout<<"
sum of series 1+3+5+.. till n
terms is: "<<s;
}
[Note:- only output matters]
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / medo
//*I know this is a different program but i want you to try
it!*//
#include <stdio.h>
void main()
{
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=8;j++)
{printf("* ");}
printf("\n");
for(j=1;j<=8;j++)
{printf(" *"); }
printf("\n");
}
}
Is This Answer Correct ? | 7 Yes | 8 No |
Answer / parthibanselvaraj
the series seems to be infinite . so you need to restrict
it to some ceiling.
Is This Answer Correct ? | 10 Yes | 19 No |
Declaration of Cube Guys please help me.. Is this a right way to declare cube.? If i Compile it. It Says: Cube undeclared what should i do? Please help \thanks in advanced #include<stdio.h> #include<math.h> #include<conio.h> main( ) { float x,y; while(x++<10.0) { printf("Enter Number:"); scanf("%d", &x); y = cube(x); printf("%f %f %f \n", x,pow(x,2),y); cube(x); } { float x; float y; y = x*x*x; } getch(); return (y); }
what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?
errors are known as?
3 Answers EX, State Bank Of India SBI,
Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;
How to reverse a linked list without using array & -1? Thank you.
quoroum of computer languages?
What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).
how tally is useful?
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
How to develop a program using C language to convert 8-bit binary values to decimals. TQ