ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a program for the following series:
1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
 Question Submitted By :: Khurshid
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer
# 1
#include<stdio.h>
			#include<conio.h>
			void main()
			  {
     int x=1,y=3,z=5,n,cal,add=0,add1=0,total,i;
			    clrscr();
  printf(" Enter Any Number to calculate Series for n 
terms :");
			    scanf("%d",&n);
			    for(i=1;i<=n;i++)
			       {
				 cal=(x*y*z);
				 x++;
				 y++;
				 z++;
				 if(i%2==1)
				   {
				     add=add+cal;
				   }
				 if(i%2==0)
				   {
				      add1=add1+cal;
				   }
				 }
			      total=add-add1;
	printf(" Total Of Series Is %d",total);
			      getch();
			    }
 
Is This Answer Correct ?    0 Yes 0 No
Anshu Porwal
 
  Re: Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer
# 2
#include<iosteram.h>
#include<conio.h>
int seri(int)
{
int r,s;
r=s*m+var;
return r;
}
void main()
{
int a[20],b[20];
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
int var=-1;
m=a[i];
cout<<m;
getch();
}
 
Is This Answer Correct ?    0 Yes 0 No
Guest
 
 
 
  Re: Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer
# 3
#include <iostream.h>

void main()
{
	int nTerm;
	int x=1,y=3,z=5,mul1,total=0;

	cout<<"Enter the NTerm:";
	cin>>nTerm;
	for(int i=1;i<=nTerm;i++)
	{
		mul1 = ((x++)*(y++)*(z++));

		if(i%2)
			total = total + mul1;
		else
			total = total - mul1;

	}
	cout<<"RESULT:"<<total<<endl;
}
 
Is This Answer Correct ?    0 Yes 0 No
Sanath
 
  Re: Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer
# 4
/*	Author : Sri K. Hari
	Description : program for series 
1*3*5-2*4*6+3*5*7-4*6*8...........upto n terms 
*/

#include<stdio.h>
#include<conio.h>

void main()
{
	int n,i,res,finres;
	char opt ;
	clrscr () ;
	do
	{
		res = 0 ;
		finres = 0 ;
		printf ( " \n Enter the last number " ) ;
		scanf("%d",&n);

		for ( i = 1 ; i <= n ;i++ )
		{
			res = ( i * (i+2) * (i+4) ) ;

			if ( (i%2) == 0 )
				finres = finres - res ;
			else
				finres = finres + res ;
		}
		printf ( " \n the result is : %d ", finres) ;
		printf ( "Do you want to continue (Y/N)" ) ;
		scanf ( "%s",&opt) ;
	}while ( (opt == 'y' ) || (opt == 'Y' ) ) ;
}
 
Is This Answer Correct ?    1 Yes 0 No
Sri K. Hari
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?  6
If we have an array of Interger values, find out a sub array which has a maximum value of the array and start and end positions of the array..The sub array must be contiguious. Take the start add to be 4000. For Ex if we have an array arr[] = {-1,-2,-5,9,4,3,-6,8,7,6,5,-3} here the sub array of max would be {8,7,6,5} coz the sum of max contiguous array is 8+7+6+5 = 26.The start and end position is 4014(8) and 4020(5). Microsoft4
What are the languages are portable and platform independent?Why they are like that? Excel1
write a program for odd numbers?  6
Which of the following about the C comments is incorrect ? a.commentscan go over multiple lines b.comments can start any where in the line c.a line can contain comments with out any language statements d.comments can occur within comments TCS6
What will be the result of the following program? main() { char p[]="String"; int x=0; if(p=="String") { printf("Pass 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } else { printf("Fail 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } } a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2 e) syntax error during compilation IBM10
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?  1
please give me some tips for the selection in TCS. TCS3
What is the output for the following program #include<stdio.h> main() { char a[5][5],flag; a[0][0]='A'; flag=((a==*a)&&(*a==a[0])); printf("%d\n",flag); } ADITI5
What kind of sorting is this? SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort Accenture3
What is encapsulation?  1
34.what are bitwise shift operators? 35.what are bit fields? What is the use of bit fields in a structure declaration? 36.what is the size of an integer variable? 37.what are the files which are automatically opened when a c file is executed? 38.what is the little endian and big endian? 39.what is the use of fflush() function? 40.what is the difference between exit() and _exit() functions? 41.where does malloc() function get the memory? 42.what is the difference between malloc() and calloc() function? 43.what is the difference between postfix and prefix unary increment operators?  2
what is the difference between c and java?  1
c programming of binary addition of two binary numbers  1
Give the output for the following program. #define STYLE1 char main() { typedef char STYLE2; STYLE1 x; STYLE2 y; clrscr(); x=255; y=255; printf("%d %d\n",x,y); } ADITI1
Give me basis knowledge of c , c++...  4
How can I call a function, given its name as a string? ABC-Telecom2
write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101) Bosch1
int a=2,b=3,c=4; printf("a=%d,b=%d\n",a,b,c); what is the o/p? Verifone6
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output CitiGroup4
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com