Under linux environment can u please provide a c code for
computing sum of series 1-2+3-4+5......n terms and
-1+2-3+4-5...n terms..
Answers were Sorted based on User's Feedback
Answer / sudhanshu_kmr
#include<stdio.h>
int main()
{
int i,n,sum=0;
printf("\n Enter the n: " );
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%2==0) /* for series is -1 +2 -3.......*/
sum= sum+i;
else
sum = sum-i;
}
printf(" Sum of %d terms is %d \n",n,sum);
return 0;
}
/* For series 1 - 2 +3 ....
then use
for(i=1;i<=n;i++)
{
if(i%2==0)
sum= sum -i;
else
sum = sum +i;
}
*/
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / sai prasad raju
I will not tell u.
Why should i tell?
off
| Is This Answer Correct ? | 1 Yes | 1 No |
void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(ā%dā, i); }
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.
16 Answers Aricent, Cisco, Directi, Qualcomm,
main() { int i=5,j=6,z; printf("%d",i+++j); }
main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }
how can u draw a rectangle in C
53 Answers Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,
main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }
main() { char a[4]="HELL"; printf("%s",a); }
write a c program to print magic square of order n when n>3 and n is odd?
1 o 1 1 0 1 0 1 0 1 1 0 1 0 1 how to design this function format in c-language ?
main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
main() { clrscr(); } clrscr();
write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display ā****ā. (Use Structures).
0 Answers CDAC, College School Exams Tests,