Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Tuesday 18 June 2019

Write a program print the pattern { 1,1,2,3,4,9,8,27,16,81,32,243.}

Question:









Credits: Swathi.

#include<stdio.h>
void main(){
     int n;
//As we are taking it in pair.
printf("Enter the limit in pairs:"); 
scanf("%d",&n);
     int even=1,odd=1;
   int i;
for(i=0;i<n;i++)
{
printf("%d,%d,",even,odd);
even*=2;
odd*=3;
}
}

0 comments:

Post a Comment