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 |
main() { clrscr(); } clrscr();
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }
How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com
why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?
Write a C function to search a number in the given list of numbers. donot use printf and scanf
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
WAP to display 1,2,3,4,5........N
How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...
6 Answers Microsoft, MSD, Oracle,
why the range of an unsigned integer is double almost than the signed integer.
What is your nationality?
Implement a t9 mobile dictionary. (Give code with explanation )
1 Answers Amazon, Peak6, Yahoo,
why nlogn is the lower limit of any sort algorithm?