NEW HAVEN — When Keila Fong arrived at Yale, she had never given much thought to computer science. But then last year everyone on campus started talking about the film “The Social Network,” and she began to imagine herself building something and starting a business that maybe, just maybe, could become the next Facebook.

“It’s become very glamorous to become the next Mark Zuckerberg, and everyone likes to think they have some great idea,” said Ms. Fong, a junior, who has since decided to major in Yale’s newly energized computer science program.

Never mind that Mr. Zuckerberg, like other tech titans, did not major in computer science — or even finish college. Enrollment in computer science programs, and degrees from them, are rising after a decade of decreases, despite much handwringing about the decline of American competitiveness in technology and innovation from President Obama on down. And educators and technologists say the inspiration is partly Hollywood’s portrayal of the tech world, as well as celebrity entrepreneurs like Steven P. Jobs of Apple and Mr. Zuckerberg who make products that students use every day.

“It’s a national call, a Sputnik moment,” said Mehran Sahami, associate chairman for computer science education at Stanford, referring to the Soviet satellite launching in 1957 that pushed the United States into the space race. “Students are users of Facebook or Google, and they think about how the people who created it are not that much different than themselves. The realization that I can do this too is a powerful motivator.”