1

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

write a program to read an integer array and find the sum of even numbers in an

array

for (i=1;i<N;i++)
{
if(max<a[i])
{
max=a[i];
}
}

write a program to read two separate integer arrays and merge two arrays to find
the max in the above array

numbers series

int a;
for (i=0;i<n;i++);
{square=i*i;
printf("square series is ",square);
}
}

void main()
{
int i,n,sum=0;
printf("Input the number of terms : ");
scanf("%d",&n);
printf("\nThe square natural upto %d terms are :",n);
for(i=1;i<=n;i++)
{
printf("%d ",i*i);
sum+=i*i;
}
printf("\nThe Sum of Square Natural Number upto %d terms = %d \n",n,sum);
}

2,6,11,10,15,21,18,24,31,26,33,41

#include <stdio.h>
int main() {
int a=2,b=6,c=11,n,i;
printf("enter a number");
scanf("%d",&n);
printf("%d%d%d",a,b,c);
for (i=1;i<n;i++)
{

printf("%d %d %d ",a=a+8,b=b+9,c=c+10);
}

return 0;
}

1,2,3,10,99,9802'

#include <stdio.h>
int main() {
int x=1,flag=1,i,n;
printf("enter a number");
scanf("%d",&n);

for (i=1;i<n;i++)
{
x=x*x;
if(flag==1)
{
x=x+1;
flag=0;

}
else if (flag==0)
{
x=x-1;
flag=1;
}

printf("%d",x);
}

return 0;
}

8,15,28,53,102,199

8==16-1
15*2=30-2
28*2=56-3
53

4096 1024 256 64 16 4

49,121,169,289,361
0,2,2,4,3,8,7,10
2,29,4,25,6,21,8,17

#include <stdio.h>
#include<math.h>
int main() {
int i,n,a=4,x=0;
printf("enter a number");
scanf("%d",&n);

for (i=0;i<n;i++)
{
x=pow(a,i);
printf("%d ",x);

return 0;
}

mutiple recurssion: -------tree,graph;

// Online C compiler to run C program online


#include <stdio.h>
int fun(int n){
if(n>0){

printf("%d ",n);
fun(n-1);
fun(n-1);

}
}
int main(){
fun(3);
}

tail recursion:

#include <stdio.h>
int fun(int n){
if(n>0){

printf("%d ",n);
fun(n-1);

}
}
int main(){
fun(500);
}

head recursion:
#include <stdio.h>
int fun(int n){
if(n>0){
fun(n-1);
printf("%d ",n);

}
}
int main(){
fun(500);
} uses stack data structure

#include <stdio.h>
int fact (int n){
if(n==1){
return 1;
}else{
return n*fact(n-1);
}
}

factorial
int main(){
int x =fact(5);
printf("fact=%d ",x);
}

#include <stdio.h>
int sum (int n){
if(n==1){
return 1;
}else{
return n+sum(n-1);
} sum till given digit
}

int main(){
int x =sum(5);
printf("sum=%d ",x);
}

void sece(cha

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy