C - INTRO - PART005

 ID:6203 Print the String S


#include<stdio.h>

#include<stdlib.h>


int main()

{

    char a[100];

    scanf("%s",&a);

    printf("%s",a);


}

ID:6166 Reverse an Array


#include<stdio.h>

#include<stdlib.h>


int main()

{

    int a;

    scanf("%d",&a);//size of the array

    int arr[100];

    int i;

    for(i=0;i<a;i++)

    {

        scanf("%d",&arr[i]);//get the array value

    }

    for(i=a-1;i>=0;--i)

    {    

        printf("% d",arr[i]);

    }

}

C PROGRAM TO PRINT LENGTH OF STRING WITHOUT USING IN-BUILT FUNCTION

#include<stdio.h>

#include<stdlib.h>


int main()

{

    char s[50],i;

    scanf("%s",s);

    for(i=0;s[i]!='\0';++i);

        

    printf("%d",i);

    

    

    return 0;

    


}

ID:6178 Count of Words in a String


#include<stdio.h>

#include<stdlib.h>


int main()

{

    char s[200];

    int count=0,i;

    scanf("%[^\n]s",s);

    for(i=0;s[i]!='\0';i++)

    {

       if(s[i]==' '&&s[i+1]!=' ')

        count++;

    }

    printf("%d",count+1);


}


ID:6172 Print the Odd Numbers in the Array in Reverse Order


#include<stdio.h>

#include<stdlib.h>


int main()

{

    int arr[100],a,i;

    scanf("%d",&a);//to enter size of Array

    for(i=0;i<a;i++){

        scanf("%d",&arr[i]);

    }

    for(i=a-1;i>=0;--i)

    {

        if(arr[i]%2!=0){

            printf("% d",arr[i]);

        }

    }


}

ID:6192 Sum of Two Integers (Call by Value)


#include <stdio.h>

int sumOfTwoNumbers(int N1,int N2){

    return N1+N2;

}

int main()

{

    int N1, N2;

    scanf("%d %d", &N1, &N2);

    printf("%d",sumOfTwoNumbers(N1, N2));

    return 0;

}


ID:6205 Reverse the String S


#include<stdio.h>

#include<string.h>


int main()

{

    char str[100];

    int i,l;

    scanf("%s",str);

    l=strlen(str);

    for(i=l-1;i>=0;i--)

    {

        printf("%c",str[i]);

    }

   


}


ID:6193 Print the Value of N(Using Pointer)


#include<stdio.h>

int main()

{

    int num;

    scanf("%d", &num);

int *ptr;

    ptr=&num;

printf("%d", *ptr);

    return 0;

}


ID:6175 Print the Transpose of a Matrix


#include<stdio.h>

#include<stdlib.h>


int main()

{

    int a[10][10],transpose[10][10],r,c,i,j;

    scanf("%d%d ",&r,&c);

    //enter the matrix

    for(i=0;i<r;++i){

        for(j=0;j<c;++j){

            scanf("%d",&a[i][j]);

        }

        

    }

    //finding the transpose of matrix

    for(i=0;i<r;++i)

        for(j=0;j<c;++j){

            transpose[j][i]=a[i][j];

        }

    for(i=0;i<c;++i)

        for(j=0;j<r;++j)

        {

            printf("%d ",transpose[i][j]);

            if(j==r-1)

                printf("\n");

        }

        return 0;


}

ID:6194 Swap Two Integers (Call by Reference/Pointer)


#include <stdio.h>

int swap(int* x,int* y){

    int temp;

    temp = *x;

    *x=*y;

    *y=temp;

    

}

int main()

{

    int X, Y;

    scanf("%d %d", &X, &Y);

    swap(&X, &Y);

    printf("%d %d",X, Y);

    return 0;

}

ID:6182 Print the Count of Vowels in String S


#include<stdio.h>

#include<stdlib.h>


int main()

{

    char s[100];int count=0,c=0;

    scanf("%s",s);

    while(s[c]!='\0')

    {

        if(s[c] == 'a' || s[c] == 'e' || s[c] == 'i' || s[c] == 'o' || s[c] == 'u' || s[c] == 'A' || s[c] == 'E' || s[c] == 'I' || s[c] == 'O' || s[c] == 'U')

            count++;

        c++;

    }

    printf("%d",count);

}


ID:6181 Concatenate Two Strings (Without Built-in Functions)


#include<stdio.h>

#include<stdlib.h>


int main()

{

    char s1[100],s2[100],i,j;

    scanf("%s",s1);// enter a string 1

    scanf("%s",s2);//enter a string 2

    for(i=0;s2[i]!='\0';++i);//this loop is used to store length of string 2

    

//this loop is used to concatenate the string1 at the end of string2

    for(j=0;s1[j]!='\0';++j,++i)

    {

        s2[i]=s1[j];

        

    }

    s2[i]='\0';

    printf("%s",s2);

    

    return 0;


}


ID:6202 Print the Name and Id (Using Structure)


#include <stdio.h>

struct employee{

    int id;

    char name[20];

}e1;

int main()

{

    struct employee e1;

    scanf("%s %d", e1.name, &e1.id);

    printf("%s %d", e1.name, e1.id);

}


ID:6191 Print the Values (Using Pointer)



#include<stdio.h>


int main()

{

    int *iptr, intval;

    char *cptr, charval;

    float *fptr, floatval;

iptr=&intval;

cptr=&charval;

fptr=&floatval;

*iptr = 80, *cptr = 'R', *fptr = 15.50;

    printf("%d %c %.3f", intval, charval, floatval);

    return 0;

}


ID:6195 Print the Value (Using Pointer and Double Pointer)


#include <stdio.h>


int main ()

{


    int  var, *ptr, **pptr;

    scanf("%d", &var);

ptr=&var;

    *pptr=&var;

    printf("%d %d %d", var, *ptr, **pptr);

    return 0;

}

ID:6199 Print the Name and Age (Using Struct Pointers)



#include<stdio.h>


struct player{

    char name[101];

    int age;

};


int main()

{

    struct player A;

 struct player *Aptr;

    Aptr=&A;

    scanf("%s %d", A.name, &A.age);

    printf("%s %d", Aptr->name, Aptr->age);

    return 0;

}

    

ID:6174 Column wise Sum of Matrix


#include<stdio.h>

#include<stdlib.h>


int main()

{

    static int array[10][10];

    int i,j,m,n,sum=0;

    //Enter The Order Of Matrix

    scanf("%d%d",&m,&n);

    //Enter Element Of Matrix

    for(i=0;i<m;++i)

    {

        for(j=0;j<n;++j)

        {

            scanf("%d",&array[i][j]);

        }

    }

    //Sum Of column

    sum=0;

    for(j=0;j<n;++j)

    {

        for(i=0;i<m;++i)

        {

            sum=sum+array[i][j];

        }

        printf("% d",sum);

        sum=0;

    }


}


ID:6196 Average of Three Numbers (Using Call by Reference)


#include <stdio.h>

int averageOfThreeIntegers(int X,int Y,int Z,float *avg)

{

   

   *avg=(X+Y+Z)/3.0;

}

int main()

{

    int X, Y, Z;

    float avg = 0;

    scanf("%d %d %d", &X, &Y, &Z);

    averageOfThreeIntegers(X, Y, Z, &avg);

    printf("%.2f", avg);

    return 0;

}


ID:6169 Print the Unit Digit of elements in Reverse Order


#include<stdio.h>

#include<stdlib.h>


int main()

{

    int N,temp[100],i;

    scanf("%d",&N);

    int arr[100];

    for(i=1;i<N+1;i++)

    {

        scanf("%d",&arr[i]);

       

    }

    for(i=N;i>0;i--)

    {

        printf("% d",arr[i]%10);

    }

    

   

}



Comments

Popular posts from this blog

alphabet matrix minimum sum path

C--Starter-part007---skillrack