1. Recursion In C
Method 1 #include<stdio.h> int isPrime(int,int); int main(){ int num,prime; printf("Enter a positive number: "); scanf("%d",&num); prime = isPrime(num,num/2); if(prime==1) printf("%d is a prime number",num); else printf("%d is not a prime number",num); return 0; } int isPrime(int num,int i){ if(i==1){ return 1; }else{ if(num%i==0) return 0; else isPrime(num,i-1); } } Output Enter a positive number: 13 […]
  1. Array In C
Method 1 #include <stdio.h> #include <stdlib.h> int main() { int *ptr,sum=0,n,i; int a[10]; ptr=a; printf(“enter the number of elements\n”); scanf(“%d”,&n); printf(“enter the array elements\n”); for(i=0;i<n;i++) scanf(“%d”,&a[i]); printf(“MEMORY LOCATION OF THE FIRST VALUE %u\n”,&ptr[0]); i=0; while(i<n) { sum=sum+(*ptr); i++; ptr++; } printf(“sum is %d\n”,sum); printf(“FINAL MEMORY LOCATION AFTER ACCESSING %d INTEGERS IS ptr=%u”,n,ptr); return 0; } […]


Welcome to WikiCoders

Join the site and store the save posts for later, share your own articles
Join WikiCoder
Registration is closed.