Showing posts with label C Programming Projects. Show all posts
Showing posts with label C Programming Projects. Show all posts

A full Pyramid Shape In C

Complied On :  Code::Blocks 17.0 Save :-  .c file (C Program) Cre…

Reverse String in C programming

Add caption Reverse String in C  :- The Purpose of Reverse String in C is …
Showing posts with label C Programming Projects. Show all posts
Showing posts with label C Programming Projects. Show all posts

A full Pyramid Shape In C



Complied On : Code::Blocks 17.0

Save :- .c file (C Program)

Created By :- Lukas Yooma 






                                                                          
#include <stdio.h>
int main()
{
    int i, space, rows, k=0;

    printf("Enter number of rows: ");
    scanf("%d",&rows);

    for(i=1; i<=rows; ++i, k=0)
    {
        for(space=1; space<=rows-i; ++space)
        {
            printf("  ");
        }

        while(k != 2*i-1)
        {
            printf("* ");
            ++k;
        }

        printf("\n");
    }

    return 0;
}
                                                                                     

C Programming- A program that calculates and displays the price before commission and after commission of 6%: The program prompt the user to enter



 A program that calculates and displays the price before commission
 and after commission of 6%: The program prompt the user to enter
i. Quality of products purchased
ii. Unit price.

Complied On : Code::Blocks 17.0

Save :- .c file (C Program)

Created By :- Lukas Yooma 


                                                                                                                                                               
#include <stdio.h>

int quantity, price, b4;
float commision;

main()
{
    printf("\nENTER THE QUANTITY OF THE PRODUCTS PURCHASED ?\n");
    scanf("%d", &quantity);

    printf("WHAT IS THE UNIT PRICE \n");
    scanf("%d", &price);

    b4=(quantity*price);

    printf(" THE PRICE BEFORE COMMISION %d\n",b4);

    commision=(b4-0.06*b4);

    printf("\nTHE PRICE AFTER THE COMMISION OF 6 PERCENT %f\n",commision);

    main(0);

}
                                                                                                                               
Thank you For reading please leave your comments for any queries 




PROGRAMMING IN C- A function which outputs all the prime numbers between 2 and a given positive integer n:



This program will allow users to find the the prime numbers between 2 and a given positive integer 


Complied On : Code::Blocks 17.0

Save :- .c file (C Program)

Created By :- Lukas Yooma 
Find the code below
                                                                                                                                                                   

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j, n=0,prime;

    printf("PLEASE ENTER THE NUMBER TO FIND ITS PRIME NUMBERS :\t");
    scanf("%d", &prime);
    for(i = 2; i <=prime; i++)
    {
        for (j=1; j<= i; j++)
        {
            if (i%j == 0)
            {
                n++;
            }
        }
        if (n == 2)
    printf("%d\n", i);
    n=0;
    }
    getchar();

    main();
}
                                                                                                                                                                
Thanks for reading, leave a comment for any queries
                                                                                                       

Programming in C - A program which inputs a person’s height (in centimeters) and weight (in kilograms) and outputs one of the messages: underweight, normal, or overweight, using the criteria:






A program which inputs a person’s height (in centimeters) and weight (in kilograms) and outputs one of the messages: underweight, normal, or overweight, using the criteria:
              Underweight:    weight < height/2.5
              Normal:             height/2.5 <= weight <= height/2.3

              Overweight:      height/2.3 < weight


Complied On : Code::Blocks 17.0

Save :- .c file (C Program)

Created By :- Lukas Yooma 
Below is the code 
                                                                                                                                            
#include <stdio.h>
#include <stdlib.h>

int main()
{
    float height, weight;

    printf("\nENTER YOUR HEIGHT IN CENTMETERS \n");
    scanf("%lf",&height);
    printf("\nENTER YOUR WEIGHT IN KILOGRAMMES \n");
    scanf("%lf", &weight);

    if(weight < height/2.5)
    printf("YOU ARE UNDERWEIGHT \n");
    else


    if(height/2.3 < weight)
    printf("YOU ARE OVERWEIGHT \n");
    else


    if(height/2.5 <= weight <= height/2.3)
    printf("YOU ARE NORMAL\n");


    main(0);
}
                                                                                                                                                                   
Thanks for reading leave a comment for any queries

Reverse String in C programming


Add caption
Reverse String in C  :-
The Purpose of Reverse String in C is to reverse sentences from the end to 
the beginning 



Complied On : Code::Blocks 17.05

Save :- .c file (C Program)

Created By :- Luka Yooma 


Below Is the code for the Reverse String



/**
 * C program to reverse order of words in a string
 */
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 100 // Maximum string size

int main()
{
    char str[100], reverse[100];
    int len, i, index, wordStart, wordEnd;

    printf("Enter any sentence:\n\t ");
    gets(str);

    len   = strlen(str);
    index = 0;

    // Start checking of words from the end of string
    wordStart = len - 1;
    wordEnd   = len - 1;

    while(wordStart > 0)
    {



        // If a word is found
        if(str[wordStart] == ' ')
        {
            // Add the word to the reverse string
            i = wordStart + 1;
            while(i <= wordEnd)
            {
                reverse[index] = str[i];

                i++;
                index++;
            }
            reverse[index++] = ' ';

            wordEnd = wordStart - 1;
        }

        wordStart--;
    }

    // Finally add the last word
    for(i=0; i<=wordEnd; i++)
    {
        reverse[index] = str[i];
        index++;
    }

    // Add NULL character at the end of reverse string
    reverse[index] = '\0';

    printf("Original sentence \n%s\n\n", str);
    printf("Reversed Sentence \n%s", reverse);

    return 0;

}




Thanks to all my Readers Leave a comment for any queries.......