#26 C Struct | C Programming for Beginners

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • #26 C Struct | C Programming for Beginners
    In this video, we will learn about struct in C programming. More specifically, we will learn to store related data together under a single name using struct. And we will also learn the use of an alias. Watch out for this video to have a clear understanding of struct in C programming.
    Sign Up to get 50% off with this link: app.programiz....
    This video is a part of our C Programming video series: • #1: Getting Started wi...
    ~
    Resources:
    C Online Compiler: www.programiz....
    Github File: github.com/pro...
    C (title) Tutorial (text-based tutorial): www.programiz....
    Timestamps:
    0:16 - C Struct
    07:35 - typedef in Struct
    08:50 - Sum of Complex Numbers
    12:38 - Programming Task
    13:17 - Quiz
    ~
    Revise your learning using our C App
    Download here for Android: bit.ly/3upaInx
    Download here for iOS: apple.co/3EZLtNq
    Find Programiz elsewhere:
    Programiz pro: programiz.pro/
    Website: www.programiz.com
    Discord: / discord
    Facebook: / programiz
    Instagram: / _programiz
    LinkedIn: / programiz
    Twitter: / programiz
    #programiz #struct #cprogramming #learnprogramming #typedef #alias

КОМЕНТАРІ • 87

  • @programizstudios
    @programizstudios  2 роки тому +4

    🔥Finding it Damn Hard to Understand C Programming?
    Learn to code-the right way-with interactive lessons, quizzes & challenges. Build a strong programming base; it's IMPORTANT!
    Try Programiz PRO for Free: bit.ly/master-c-programming

    • @AbhiramDeshpande-fe1vi
      @AbhiramDeshpande-fe1vi Рік тому +1

      #include
      typedef struct complex
      {int real;
      int imaginary;}
      complex;
      int main() {
      complex c1 = {.real=12,.imaginary=9};
      complex c2 = {.real=3,.imaginary=2};
      complex c3 = {.real=7,.imaginary=8};
      complex difference;
      difference.real= c1.real-c2.real-c3.real;
      difference.imaginary=c1.imaginary-c2.imaginary-c3.imaginary;
      printf("the sum is %d%di",difference.real,difference.imaginary);
      return 0;
      }

  • @tasneembendhia2675
    @tasneembendhia2675 8 місяців тому +27

    I like when she says "let me sow you" instead of "show", it's just so cute

  • @jmarkyt5453
    @jmarkyt5453 Рік тому +21

    #include
    #include
    #include
    #include
    typedef struct Complex {
    int real;
    int imagine;
    } complex;
    int main()
    {
    complex c1 = {.real = 10, .imagine = 20};
    complex c2 = {.real = 5, .imagine = 15};
    complex c3 = {.real = 25, .imagine = 30};
    complex minus;
    minus.real = c1.real - c2.real - c3.real;
    minus.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Total is: %d and %di", minus.real, minus.imagine);
    return 0;
    }
    OUTPUT:
    Total is: -20 and -25i

  • @bryanbalantes6486
    @bryanbalantes6486 Рік тому +7

    /*
    Create a program to find the differences
    between three complex numbers.
    * Perform the subtraction between
    complex numbers by subtracting the
    real part of one complex number from
    other complex numbers and same for
    the imaginary part too.
    */
    #include
    //Differences of Complex Numbers
    typedef struct Complex{
    double real;
    double imagine;
    }complex;
    int main(){
    complex c1 = {.real = 45.34, .imagine = 15};
    complex c2 = {.real = 21.34, .imagine = 30};
    complex c3 = {.real = 13.34, .imagine = 10.5};

    complex sub;
    sub.real = c1.real - c2.real - c3.real;
    sub.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Result is %.2lf - %.2lfi", sub.real, sub.imagine);

    return 0;
    }

  • @Frank-mu6qy
    @Frank-mu6qy Рік тому +4

    Very basic tutorial but high-quality for beginner,expecting more videos for C language

  • @tteokmember
    @tteokmember Рік тому +7

    you have helped many all around the world a lot! thank you so much!

  • @questionbaba
    @questionbaba 2 роки тому +4

    I'm also learning c programming language. Your Program learn trick very amazing mam ❤️ Thank you so much love u mam ❤️❤️

  • @Abdullah-un8go
    @Abdullah-un8go 6 місяців тому +1

    i have one question what is the main use for struct as more variable can be take to do the work? Is it related to memory of operation check?

  • @swahifaabdijuma2782
    @swahifaabdijuma2782 9 місяців тому +1

    Amaizing Thank youuuuuuuuu I havew lab of programming tomorrow and is about this thank uuuuuuuuuuuuuuuuuuuuuuuuuuu

  • @yogithabale
    @yogithabale Місяць тому +2

    opt c , first test

  • @questionbaba
    @questionbaba 2 роки тому +4

    At the last in quiz answer will be....(c) firstTest 💥💥💥💥

  • @ndyakuhakiwilberforce9675
    @ndyakuhakiwilberforce9675 Місяць тому

    Thanks

  • @Farhadpeymani
    @Farhadpeymani Рік тому +1

    Thank you so much. Tnx for sharing your knowledge generously.

  • @wilsonvaler1717
    @wilsonvaler1717 2 роки тому +1

    Hi Panoha, i'm from Peru (latinoamerica), your videos are amazing thank for it, that i help me a lots.

  • @iremtaze6262
    @iremtaze6262 Рік тому +1

    Thanks a lot for the video, but I have one question. 9:30 Why did we add "Complex" after the "typedef struct"? We did not use "Complex" anywhere in the last version of the code. And without using it, the program still works.

    • @tylers6071
      @tylers6071 Рік тому +2

      This is because she used "typedef" at the beginning of the definition. By doing so, she created an alias of "complex" which represents "struct Complex". So anywhere in the code that you see "complex" that is substituting for "struct Complex".

  • @stealthy_doctor
    @stealthy_doctor 8 днів тому

    Hello again! i am back at it finally and here is my solution for the Programming task:
    #include
    typedef struct complex{
    double real;
    double imaginary;
    }complex;
    int main(){

    complex num1 = {.real = 121.05, .imaginary = 130.1};
    complex num2 = {.real = 20.05, .imaginary = 30.2};
    complex num3 = {.real = 2, .imaginary = 30.3};
    complex sum;
    sum.real = num1.real - num2.real - num3.real;
    sum.imaginary = num1.imaginary - num2.imaginary - num3.imaginary;
    printf("Result of %.2lf + %.2lfi", sum.real, sum.imaginary);
    return 0;
    }
    and for the quiz i'm thinking C. firstTest because if i'm not mistaken that's how you create a quick nickname thing
    (just fyi i looked it up now its not a nickname, its like you're initializing or declaring a variable of that struct type immediately after defining the structure itself, which i think is neat to know )

  • @ironmonkey1990
    @ironmonkey1990 6 місяців тому +1

    very helpfull!

  • @user-qc1rq2rk3l
    @user-qc1rq2rk3l 7 місяців тому

    Mam I need more structure videos such as pointer to structure,self referencial structure and singly linked list please post these videos for me

  • @avdeshsingh001
    @avdeshsingh001 Рік тому

    Your video are crisp and easy to understand

  • @Whosumitmishraa
    @Whosumitmishraa 2 роки тому +1

    Big fan of your sites and videos 😜

  • @user-tb5yv7ee5o
    @user-tb5yv7ee5o 11 місяців тому

    Mam explain this program in the next vedio write a c program to read a sentence and count the number of pf words in the sentence

  • @bennarthurdesouza1624
    @bennarthurdesouza1624 Рік тому

    Thanks for this explanation!

  • @srinivaschilla9881
    @srinivaschilla9881 Рік тому +2

    Maadam miruu thopp🔥💥

  • @user-to5rz4kc3i
    @user-to5rz4kc3i Рік тому +1

    #include
    typedef struct Complex {
    double real;
    double imagine;
    } complex;
    int main() {
    complex c1 = {.real = 3496.54, .imagine = 67.07};
    complex c2 = {.real = 672.41, .imagine = 23.14};
    complex c3 = {.real = 27.06, .imagine = 42.15};
    complex subtraction;
    subtraction.real = c1.real - c2.real - c3.real;
    subtraction.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Result is %.2lf + %.2lfi", subtraction.real, subtraction.imagine);
    return 0;
    }

  • @ikechukwuunegbu7266
    @ikechukwuunegbu7266 2 роки тому

    Great job. Thank you for this.

  • @oluwatomirhodes795
    @oluwatomirhodes795 5 місяців тому

    I am having problems with C progamming for engineers I am worried I will not do well on my finaly exam as I need 20%out of 40% to pass. That's what I am here. Seeking help. Please do you have a detailed video as to why you use the typedef and other methods of initializing struts. I don't mined I will pay for it

  • @stormstylz3447
    @stormstylz3447 9 місяців тому

    Thank you!

  • @twinkleramchandani5193
    @twinkleramchandani5193 27 днів тому

    option d

  • @avdeshsingh001
    @avdeshsingh001 Рік тому

    Thanks ma'am

  • @prathikantamsaivarnith484
    @prathikantamsaivarnith484 Рік тому

    #include
    typedef struct complex{
    double real;
    double imaginary;
    } complex;
    int main(){
    complex c1={.real=23.26 , .imaginary=15.56};
    complex c2={.real=13.26 , .imaginary=5.56};
    complex subtract;
    subtract.real=c1.real - c2.real;
    subtract.imaginary=c1.imaginary - c2.imaginary;
    printf("difference between c1 and c2 is %.2lf + %.2lfi",subtract.real,subtract.imaginary);
    return 0;
    }

  • @thiagaodavez5465
    @thiagaodavez5465 Рік тому +1

    comment leaved

  • @abdirahmaanabdirashiid
    @abdirahmaanabdirashiid 12 днів тому

    #include
    typedef struct complex{
    double real;
    double imagine;
    }complex;
    int main()
    {
    complex x={.real=73.7, .imagine=143.8};
    complex y={.real=45.3, .imagine=112.4};
    complex substract={.real=x.real-y.real, .imagine=x.imagine-y.imagine};
    printf("RESULT: %.1lf + %.1lfi",substract.real,substract.imagine);
    return 0;
    }

  • @programizstudios
    @programizstudios  2 роки тому +8

    Quiz: What is the name of the variable of the following struct?
    struct Test {
    double testScore;
    int testCount;
    } firstTest;
    a. testScore
    b. struct
    c. firstTest
    d. Test

  • @surekingu5719
    @surekingu5719 8 місяців тому

    I try take string value in struct but not work...how to solve.?

  • @Jarawain_Kharpran
    @Jarawain_Kharpran Рік тому

    ty

  • @user-iu3fd4is4e
    @user-iu3fd4is4e Рік тому

    You are the best❤

  • @user-mk9oz2fn5c
    @user-mk9oz2fn5c 2 місяці тому

    Answer is option c mam

  • @All4you_
    @All4you_ 2 роки тому

    Mam, When will the searching and sorting video come out in this series?

  • @user-tt2yu8tc5r
    @user-tt2yu8tc5r 5 місяців тому

    First test

  • @aderolearnsengineering
    @aderolearnsengineering 11 місяців тому +1

    C. firstTest

  • @PraveenPraveen-us3rp
    @PraveenPraveen-us3rp 11 місяців тому

    Option : test

  • @keshavdixit08
    @keshavdixit08 Рік тому

    answer : C

  • @ashirafuSalum
    @ashirafuSalum 9 місяців тому

    firstTest

  • @tanzimkhan4695
    @tanzimkhan4695 9 місяців тому

    Your Laptop Spec. ?🤩🤩

  • @seabasschukwu6988
    @seabasschukwu6988 Рік тому

  • @shaikhmuhammadbakhtawarahm7533
    @shaikhmuhammadbakhtawarahm7533 2 роки тому

    first test

  • @freehug071
    @freehug071 Рік тому +1

    #include
    typedef struct complex{
    double Real;
    double Imaginary;
    } complex;
    int main()
    {
    complex a1 = {.Real = 43.2, .Imaginary =23.32};
    complex a2 = {.Real = 34.44, .Imaginary = 32.33};
    complex sum;
    sum.Real = a1.Real - a2.Real;
    sum.Imaginary = a1.Imaginary - a2.Imaginary;
    printf("the Real of complex is %.1lf
    the Imaginary of complex is %.2lf
    ", sum.Real, sum.Imaginary);
    return 0;
    }

  • @vinaykumarvinaykumar2006
    @vinaykumarvinaykumar2006 Рік тому

    My Answer is c

  • @bbek300
    @bbek300 4 місяці тому

    #include
    typedef struct complex{
    double real;
    double imaginary;
    }comp;
    int main() {
    comp c1 = { .real=41.5, .imaginary=20};
    comp c2 = {.real=10.6, .imaginary=5};
    comp c3 = {.real=15.2, .imaginary=2.3};
    comp diff;
    diff.real=c1.real-c2.real-c3.real;
    diff.imaginary=c1.imaginary-c2.imaginary-c3.imaginary;
    printf("The Difference is %.2lf + %.2lfi",diff.real,diff.imaginary);
    return 0;
    }

  • @imrannazari8642
    @imrannazari8642 Рік тому

    c

  • @aritradey7189
    @aritradey7189 2 роки тому

    c.firstTest

  • @user-fo7cn4dn6e
    @user-fo7cn4dn6e 5 місяців тому

    typedef struct complexnum {
    int real, imag;
    } complexnum;
    int main() {
    int resultreal, resultimag;
    complexnum c1 = {.real = 8, .imag = 5 };
    complexnum c2 = {.real = 6, .imag = 2 };
    complexnum c3 = {.real = 3, .imag = 7 };
    resultreal = c1.real - c2.real - c3.real;
    resultimag = c1.imag - c2.imag - c3.imag;
    printf("the result is: Z=%d%di
    ", resultreal, resultimag);
    return 0;

  • @davebull6321
    @davebull6321 Рік тому

    # include
    typedef struct Difference {
    double real;
    double imaginary;
    double answer;
    }difference;
    int main() {
    difference c1 = {.real = 34.14, .imaginary = 112.34};
    difference c2 = {.real = 21.12, .imaginary = 80.21};
    difference minus;
    minus.real = c1.real - c2.real;
    minus.imaginary = c1.imaginary - c2.imaginary;
    minus.answer = minus.imaginary - minus.real;
    printf("Result is %.2lf - %.2lf = %.2lf",minus.imaginary,minus.real,minus.answer);
    return 0;
    }

  • @onic9623
    @onic9623 Рік тому +1

    Option C : firstTest
    ---------------------------------------------------------------------------------
    #include
    typedef struct complex
    {
    double real;
    double imagine;
    }complex;
    int main()
    {
    complex c1 = {.real = 23.56, .imagine = 47.2};
    complex c2 = {.real = 11.28, .imagine = 25.7};
    complex c3 = {.real = 9.38, .imagine = 14.4};
    complex diff;
    diff.real = c1.real - c2.real - c3.real;
    diff.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Difference is %.2lf - %.2lfi", diff.real, diff.imagine);
    return 0;
    }

  • @JASMIN-jg2vn
    @JASMIN-jg2vn 2 місяці тому

    #include
    typedef struct Complex {
    double real;
    double imagine;
    } complex;
    int main() {
    complex c1 = {.real = 144.8, .imagine = 188.4};
    complex c2 = {.real = 84.6, .imagine = 68.55};
    complex c3 = {.real = 48.9, .imagine = 24.6};
    complex difference;
    difference.real = c1.real - c2.real - c3.real;
    difference.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Result is %.2lf + %.2lfi", difference.real, difference.imagine);

    return 0;
    }
    output: Result is 11.30 + 95.25i

  • @swabulabdul2393
    @swabulabdul2393 Рік тому +1

    #include
    typedef struct Numbers{
    double real;
    double imagine;
    }numbers;
    int main(){
    numbers n1 = {.real = 600, .imagine = 300};
    numbers n2 = {.real = 200, .imagine = 200};
    numbers n3 = {.real = 100, .imagine = 100};
    numbers diff;
    diff.real = n1.real - n2.real - n3.real;
    diff.imagine = n1.imagine - n2.imagine - n3.imagine;
    printf("The difference is: %.2lf + %.2lfi", diff.real, diff.imagine);
    return 0;

  • @huwagmunatayongumuwi
    @huwagmunatayongumuwi 13 днів тому

    #include
    typedef struct Complex {

    double real;
    double imaginary;
    } complex ;
    int main() {

    complex num1 = {.real = 123.32, .imaginary = 69};
    complex num2 = {.real = 312.35, .imaginary = 63};
    complex num3 = {.real = 323.32, .imaginary = 609};
    complex difference;
    difference.real = num1.real - num2.real - num3.real ;
    difference.imaginary = num1.imaginary - num2.imaginary - num3.imaginary ;
    printf("The difference of the three complex numbers are %.2lf - %.2lfi ", difference.real, difference.imaginary);
    return 0;
    }

  • @Eileen-in-the-coding-maschine
    @Eileen-in-the-coding-maschine 7 місяців тому

    Task:
    #include
    struct Complex {
    double real;
    double imagine;
    };
    int main() {
    struct Complex complex1 = {.real = 35.56, .imagine = 45};
    struct Complex complex2 = {.real = 45.76, .imagine = 75.67};
    struct Complex complex3 = {.real = 105.86, .imagine = 146.98};
    struct Complex sub;
    sub.real = complex3.real - complex2.real - complex1.real;
    sub.imagine = complex3.imagine - complex2.imagine - complex1.imagine;
    printf("Result: %.2lf + %.2lfi ", sub.real, sub.imagine);
    OUTPUT: Result: 24.54 + 26.31i
    Quiz: C is the correct option

  • @heevar6169
    @heevar6169 Рік тому

    #include
    typedef struct Complex {
    double real;
    double imagine;
    }complex;
    int main(){
    complex c1 = {.real = 11.12 , .imagine = 13.14};
    complex c2 = {.real = 14.15 , .imagine = 15.16};
    complex c3 = {.real = 16.17 , .imagine = 17.18};
    complex sub;
    sub.real = (c1.real) - (c2.real) - (c3.real) ;
    sub.imagine = (c1.imagine) - (c2.imagine) - (c3.imagine) ;
    printf("%.2lf + %.2lfi ", sub.real , sub.imagine);


    return 0;
    }

  • @user-jt3dx4zv3u
    @user-jt3dx4zv3u Рік тому

    #include
    typedef struct Complex{
    double real;
    double imaginary;
    } complex;
    int main(){
    double imaginary;
    complex c1 = {.real =5, imaginary = 2};
    complex c2 = {.real =2, imaginary = 4};
    complex c3 = {.real =7, imaginary = 1};
    complex sub1,sub2,sub3;
    sub1.real = c1.real - c2.real;
    sub2.real = c2.real - c3.real;
    sub3.real = c3.real - c1.real;
    sub1.imaginary = c1.imaginary -c2.imaginary;
    sub2.imaginary = c2.imaginary -c3.imaginary;
    sub3.imaginary = c3.imaginary -c1.imaginary;
    printf("c1- c2 is %.2lf + (%.2lfi)
    ", sub1.real ,sub1.imaginary);
    printf("c2- c3 is %.2lf + (%.2lfi)
    ", sub2.real ,sub2.imaginary);
    printf("c3- c1 is %.2lf + (%.2lfi)", sub3.real ,sub3.imaginary);
    return 0;
    }

  • @sadewnivihidula5505
    @sadewnivihidula5505 11 місяців тому

    firstTest

  • @mahisflow1165
    @mahisflow1165 2 роки тому

    First test

  • @1NazareeM618
    @1NazareeM618 Рік тому

    Thanks

  • @countrysideshowyaigrock4689

    #include
    typedef struct Complex {
    double real;
    double imagine;
    } complex;
    int main() {
    complex c1 = {.real = 221.87, .imagine = 330};
    complex c2 = {.real = 13.34, .imagine = 112.23};
    complex c3 = {.real = 27.13, .imagine = 22.16};
    complex sub;
    sub.real = c1.real - c2.real - c3.real;
    sub.imagine = c1.imagine - c2.imagine - c3.imagine;
    printf("Result is %.2lf + %.2lfi", sub.real, sub.imagine);
    return 0;
    }